namespace Organizer.Server.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class rewrite2 : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.Wishes", "IMDb_MovieId", "dbo.Movies");
            DropForeignKey("dbo.CharacterPersons", "Person_PersonId", "dbo.People");
            DropForeignKey("dbo.CharacterPersons", "Character_CharacterId", "dbo.Characters");
            DropIndex("dbo.Wishes", new[] { "IMDb_MovieId" });
            DropIndex("dbo.CharacterPersons", new[] { "Person_PersonId" });
            DropIndex("dbo.CharacterPersons", new[] { "Character_CharacterId" });
            AlterColumn("dbo.Wishes", "Name", c => c.String(nullable: false));
            AlterColumn("dbo.Wishes", "IMDb_MovieId", c => c.Int(nullable: false));
            AlterColumn("dbo.Movies", "Name", c => c.String(nullable: false));
            AlterColumn("dbo.People", "Name", c => c.String(nullable: false));
            AlterColumn("dbo.CharacterPersons", "Person_PersonId", c => c.Int(nullable: false));
            AlterColumn("dbo.CharacterPersons", "Character_CharacterId", c => c.Int(nullable: false));
            AlterColumn("dbo.Characters", "Name", c => c.String(nullable: false));
            AddForeignKey("dbo.Wishes", "IMDb_MovieId", "dbo.Movies", "MovieId", cascadeDelete: true);
            AddForeignKey("dbo.CharacterPersons", "Character_CharacterId", "dbo.Characters", "CharacterId", cascadeDelete: true);
            AddForeignKey("dbo.CharacterPersons", "Person_PersonId", "dbo.People", "PersonId", cascadeDelete: true);
            CreateIndex("dbo.Wishes", "IMDb_MovieId");
            CreateIndex("dbo.CharacterPersons", "Character_CharacterId");
            CreateIndex("dbo.CharacterPersons", "Person_PersonId");
        }
        
        public override void Down()
        {
            DropIndex("dbo.CharacterPersons", new[] { "Person_PersonId" });
            DropIndex("dbo.CharacterPersons", new[] { "Character_CharacterId" });
            DropIndex("dbo.Wishes", new[] { "IMDb_MovieId" });
            DropForeignKey("dbo.CharacterPersons", "Person_PersonId", "dbo.People");
            DropForeignKey("dbo.CharacterPersons", "Character_CharacterId", "dbo.Characters");
            DropForeignKey("dbo.Wishes", "IMDb_MovieId", "dbo.Movies");
            AlterColumn("dbo.Characters", "Name", c => c.String());
            AlterColumn("dbo.CharacterPersons", "Character_CharacterId", c => c.Int());
            AlterColumn("dbo.CharacterPersons", "Person_PersonId", c => c.Int());
            AlterColumn("dbo.People", "Name", c => c.String());
            AlterColumn("dbo.Movies", "Name", c => c.String());
            AlterColumn("dbo.Wishes", "IMDb_MovieId", c => c.Int());
            AlterColumn("dbo.Wishes", "Name", c => c.String());
            CreateIndex("dbo.CharacterPersons", "Character_CharacterId");
            CreateIndex("dbo.CharacterPersons", "Person_PersonId");
            CreateIndex("dbo.Wishes", "IMDb_MovieId");
            AddForeignKey("dbo.CharacterPersons", "Character_CharacterId", "dbo.Characters", "CharacterId");
            AddForeignKey("dbo.CharacterPersons", "Person_PersonId", "dbo.People", "PersonId");
            AddForeignKey("dbo.Wishes", "IMDb_MovieId", "dbo.Movies", "MovieId");
        }
    }
}
